package maven.jyhs.com.servlet;


import maven.jyhs.com.entity.Sea;
import maven.jyhs.com.proxy.dynamic.CglibProxyFactory;
import maven.jyhs.com.servce.TranstfeSevrce;
import maven.jyhs.com.servce.impl.TranstfeSevrceImpl;
import maven.jyhs.com.util.Reflection;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;

@WebServlet(urlPatterns = "/searchServlet")
public class SearchServlet extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        TranstfeSevrce service = CglibProxyFactory.createProxy(new TranstfeSevrceImpl());
        resp.setContentType("application/json;charset=UTF-8");
        resp.setCharacterEncoding("utf-8");
        Sea sea =new Sea();
        try {
            Reflection.httpServletToObject(req, sea);
            sea.setName("name");
            sea.setShoname("shoname");
            sea.setZhangsj(Date.valueOf("zhangsj"));
            service.search(sea);

        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
